package org.icnmasjid.member.webapp.action;

import java.net.URLEncoder;
import java.security.InvalidKeyException;
import java.sql.Timestamp;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.math.NumberUtils;
import org.icnmasjid.member.Constants;
import org.icnmasjid.member.util.CommonUtil;
import org.icnmasjid.member.util.DesEncrypter;
import org.icnmasjid.member.webapp.action.BaseFormController;
import org.icnmasjid.member.model.Person;
import org.icnmasjid.member.model.PersonPayment;
import org.icnmasjid.member.model.PersonSubOrgRole;
import org.icnmasjid.member.model.Role;
import org.icnmasjid.member.model.SubOrg;
import org.icnmasjid.member.service.PersonManager;
import org.icnmasjid.member.service.impl.BaseManager;
import org.springframework.validation.BindException;
import org.springframework.web.servlet.ModelAndView;

import com.sun.mail.iap.Response;

public class StudentPaymentsController extends BaseFormController {

	private PersonManager personManager;

    public void setPersonManager(PersonManager personManager) {
        this.personManager = personManager;
    }

    public StudentPaymentsController() {
    	setCommandClass(Person.class);
    	setCommandName("person");
	}

    @Override
    protected boolean isFormSubmission(HttpServletRequest request) {
    	return true;
    }

    public ModelAndView onSubmit(HttpServletRequest request,
                                 HttpServletResponse response, Object command,
                                 BindException errors)
    throws Exception {
        if (log.isDebugEnabled()) {
            log.debug("entering 'onSubmit' method...");
        }
        Locale locale = request.getLocale();
        Person p = new Person();
        p.setRole((Role)personManager.getObject(Role.class, Long.valueOf("1")));
        List<Person> persons = personManager.getPersons(p);
        return new ModelAndView("studentPaymentsList",Constants.PERSON_LIST, persons);
    }
}
